package es.indra.malaga.managedBeans;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;

import es.indra.malaga.delegates.IAsignaturaDelegates;
import es.indra.malaga.filters.NavigationFilter;
import es.indra.malaga.viewBeans.AsignaturaView;

public class AsignaturasBean extends NavigationFilter {

	private List<AsignaturaView> dataListAsignaturas = new ArrayList<AsignaturaView>();
	private List<AsignaturaView> selectionItems = new ArrayList<AsignaturaView>();

	private static String BEANEDITARASIGNATURA = "editarAsignatura";
	private static String BEANGUARDARASIGNATURA = "guardarAsignatura";
	private static String REDIRECCIONALTA = "nuevaAsignatura";

	private IAsignaturaDelegates asignaturaDelegates;
	private AsignaturaView asignaturaEditar;
	private int currentAsignaturaIndex;

	public AsignaturasBean() {
	}

	@PostConstruct
	public void init() {
		asignaturaEditar = new AsignaturaView();
	}

	private void cargarListaAsignaturas() {
		dataListAsignaturas = asignaturaDelegates.getListadoAsignaturas();
	}

	public String guardarAsignatura() {
		asignaturaDelegates.actualizarAsignatura(asignaturaEditar);
		return "";
	}

	public String altaAsignatura() {
		asignaturaDelegates.saveAsignatura(asignaturaEditar);
		asignaturaEditar = new AsignaturaView();
		return "/view/asignaturas/ListadoAsignaturas";
	}

	public AsignaturaView getAsignaturaEditar() {
		return asignaturaEditar;
	}

	public void setAsignaturaEditar(AsignaturaView asignaturaEditar) {
		this.asignaturaEditar = asignaturaEditar;
	}

	public String redirigirAlta() {
		return REDIRECCIONALTA;
	}

	public List<AsignaturaView> getDataListAsignaturas() {
		cargarListaAsignaturas();
		return dataListAsignaturas;
	}

	public void setDataListAsignaturas(List<AsignaturaView> dataListAsignaturas) {
		this.dataListAsignaturas = dataListAsignaturas;
	}

	public List<AsignaturaView> getSelectionItems() {
		return selectionItems;
	}

	public void setSelectionItems(List<AsignaturaView> selectionItems) {
		this.selectionItems = selectionItems;
	}

	public IAsignaturaDelegates getAsignaturaDelegates() {
		return asignaturaDelegates;
	}

	public void setAsignaturaDelegates(IAsignaturaDelegates asignaturaDelegates) {
		this.asignaturaDelegates = asignaturaDelegates;
	}

	public int getCurrentAsignaturaIndex() {
		return currentAsignaturaIndex;
	}

	public void setCurrentAsignaturaIndex(int currentAsignaturaIndex) {
		this.currentAsignaturaIndex = currentAsignaturaIndex;
	}

	public String hola() {
		System.out.println("Hola");
		return "/access/login";
	}

	public String adios() {
		System.out.println("Adios");
		return "/access/login";
	}
}
